<template>
  <div v-if="isLoading">加载中...</div>
  <div v-if="error">{{ error }}</div>
  <ul v-else style="list-style:none">
    <li v-for="user in users" :key="user.id">{{ user.username }}</li>
  </ul>
</template>
<script setup>
import { ref, onMounted } from 'vue';
import http from "../utils/http"

const users = ref([]);
const isLoading = ref(false);
const error = ref(null);

onMounted(async () => {
  try {
    isLoading.value = true;
    const response = await http.get('/jwt/vip/queryAllUser');
    if (response.data.code === 200) {
      users.value = response.data.result;
    }
  } catch (err) {

    console.log(err.status)
    error.value = err.message || '加载失败';
  } finally {
    isLoading.value = false;
  }
});
</script>
